{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "<h1>Distances</h1>\n",
    "<p>In this notebook, we will use sktime for time series distance computation</p>\n",
    "<h3>Preliminaries</h3>"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "\n",
    "from sktime.datasets import load_macroeconomic\n",
    "from sktime.distances import distance"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "<h2>Distances</h2>\n",
    "The goal of a distance computation is to measure the similarity between the time series\n",
    "'x' and 'y'. A distance function should take x and y as parameters and return a float\n",
    "that is the computed distance between x and y. The value returned should be 0.0 when\n",
    "the time series are the exact same, and a value greater than 0.0 that is a measure of\n",
    "distance between them, when they are different.\n",
    "\n",
    "Take the following two time series:"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [
    {
     "data": {
      "text/plain": "<matplotlib.legend.Legend at 0x7ffa8b8beaf0>"
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZEAAAEGCAYAAACkQqisAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8/fFQqAAAACXBIWXMAAAsTAAALEwEAmpwYAABHnElEQVR4nO3dd5xcdb34/9d72vaW7dmS3U3vIR1IACMKQgBRpKkU9SJe8QrXBlz7FX8iesEv3CuiKFaKCNKFEAgJJAHSe8/uZjfbe5v++f1xzpaElM2yu7Pl/Xw8zuPMnDkz53PCMu/5tPdH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OoNnHGNMENIjIUvvQ54G3TvGWPhGRNLuzHOAurOY5RCSlc4SbiKRhpVDfZT/PsPdRwHewmtTUKKNBRI0IxhpmeCVwlYjsx2rGCffIuPwOcBjrC/D/AZ1L4W7Fyta6B/ibfd7JPAY8LNYqgE6sms+9IrIV2AKcc5L33Sci20VkB7AWq//hTNxof8Y2rHXQf3yG7+8iIj8XkTKsgFsmIj+0X7oA2Csi+7BWtev8d5sKbLDv8U3gZ8aYXfZr3xKR3VhNfy8YYzo75tUookN81YgkIucAjwNXdq6drpTqfxpElFJK9Zk2ZymllOozDSJKKaX6TIOIUkqpPtMgopRSqs80iCillOozDSJKKaX67P8H9ZJJGUzEeBkAAAAASUVORK5CYII=\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "X = load_macroeconomic()\n",
    "country_d, country_c, country_b, country_a = np.split(X[\"realgdp\"].to_numpy()[3:], 4)\n",
    "\n",
    "plt.plot(country_a, label=\"County D\")\n",
    "plt.plot(country_b, label=\"Country C\")\n",
    "plt.plot(country_c, label=\"Country B\")\n",
    "plt.plot(country_d, label=\"Country A\")\n",
    "plt.xlabel(\"Quarters from 1959\")\n",
    "plt.ylabel(\"Gdp\")\n",
    "plt.legend()"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "The above shows a made up scenario comparing the gdp growth of four countries (country\n",
    "A, B, C and D) by quarter from 1959. If our task is to determine how different country\n",
    "C is from our other countries one way to do this is to measure the distance between\n",
    "each country.\n",
    "<br>\n",
    "\n",
    "How to use the distance module to perform tasks such as these, will now be outlined."
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "<h2>Distance module</h2>\n",
    "To begin using the distance module we need at least two time series, x and y and they\n",
    "must be numpy arrays. We've established the various time series we'll be using for this\n",
    "example above as country_a, country_b, country_c and country_d. To compute the distance\n",
    "between x and y we can use a euclidean distance as shown:"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "outputs": [
    {
     "data": {
      "text/plain": "27014.721294922445"
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Simple euclidean distance\n",
    "distance(country_a, country_b, metric=\"euclidean\")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "Shown above taking the distance between country_a and country_b, returns a singular\n",
    "float that represents their similarity (distance). We can do the same again but compare\n",
    "country_d to country_a:"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "outputs": [
    {
     "data": {
      "text/plain": "58340.14674572803"
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "distance(country_a, country_d, metric=\"euclidean\")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "Now we can compare the result of the distance computation and we find that country_a is\n",
    "closer to country_b than country_d (27014.7 < 58340.1).\n",
    "\n",
    "We can further confirm this result by looking at the graph above and see the green line\n",
    " (country_b) is closer to the red line (country_a) than the orange line (country d).\n",
    "<br>\n",
    "<h3>Different metric parameters</h3>\n",
    "Above we used the metric \"euclidean\". While euclidean distance is appropriate for simple\n",
    "example such as the one above, it has been shown to be inadequate when we have larger\n",
    "and more complex timeseries (particularly multivariate). While the merits of each\n",
    "different distance won't be described here (see documentation for descriptions of each),\n",
    "a large number of specialised time series distances have been implement to get a better\n",
    "accuracy in distance computation. These are:\n",
    "<br><br>\n",
    "'euclidean', 'squared', 'dtw', 'ddtw', 'wdtw', 'wddtw', 'lcss', 'edr', 'erp'\n",
    "<br><br>\n",
    "\n",
    "All of the above can be used as a metric parameter. This will now be demonstrated:"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Euclidean distance:  58340.14674572803\n",
      "Squared euclidean distance:  3403572722.3130813\n",
      "Dynamic time warping distance:  3403572722.3130813\n",
      "Derivative dynamic time warping distance:  175072.58701887555\n",
      "Weighted dynamic time warping distance:  1701786361.1565406\n",
      "Weighted derivative dynamic time warping distance:  87536.29350943778\n",
      "Longest common subsequence distance:  1.0\n",
      "Edit distance for real sequences distance:  1.0\n",
      "Edit distance for real penalty distance:  411654.25899999996\n"
     ]
    }
   ],
   "source": [
    "print(\"Euclidean distance: \", distance(country_a, country_d, metric=\"euclidean\"))\n",
    "print(\"Squared euclidean distance: \", distance(country_a, country_d, metric=\"squared\"))\n",
    "print(\"Dynamic time warping distance: \", distance(country_a, country_d, metric=\"dtw\"))\n",
    "print(\n",
    "    \"Derivative dynamic time warping distance: \",\n",
    "    distance(country_a, country_d, metric=\"ddtw\"),\n",
    ")\n",
    "print(\n",
    "    \"Weighted dynamic time warping distance: \",\n",
    "    distance(country_a, country_d, metric=\"wdtw\"),\n",
    ")\n",
    "print(\n",
    "    \"Weighted derivative dynamic time warping distance: \",\n",
    "    distance(country_a, country_d, metric=\"wddtw\"),\n",
    ")\n",
    "print(\n",
    "    \"Longest common subsequence distance: \",\n",
    "    distance(country_a, country_d, metric=\"lcss\"),\n",
    ")\n",
    "print(\n",
    "    \"Edit distance for real sequences distance: \",\n",
    "    distance(country_a, country_d, metric=\"edr\"),\n",
    ")\n",
    "print(\n",
    "    \"Edit distance for real penalty distance: \",\n",
    "    distance(country_a, country_d, metric=\"erp\"),\n",
    ")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "While many of the above use euclidean distance at their core, they change how it is\n",
    "used to account for various problems we encounter with time series data such as:\n",
    "alignment, phase, shape, dimensions etc. As mentioned for specific details on how to\n",
    "best use each distance and what it does see the documentation for that distance.\n",
    "\n",
    "<h3>Custom parameters for distances</h3>\n",
    "In addition each distance has a different set of parameters. How these are passed to\n",
    "the 'distance' function will now be outlined using the 'dtw' example. As stated for\n",
    "specific parameters for each distance please refer to the documentation.\n",
    "<br><br>\n",
    "Dtw is a O(n^2) algorithm and as such a point of focus has been trying to optimise the\n",
    "algorithm. A proposal to improve performance is to restrict the potential alignment\n",
    "path by putting a 'bound' on values to consider when looking for an alignment. While\n",
    "there have been many bounding algorithms proposed the two most popular are Sakoe-Chiba\n",
    "bounding or Itakuras parallelogram bounding. How these two work will briefly be\n",
    "outlined using the LowerBounding class:"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "outputs": [
    {
     "data": {
      "text/plain": "array([[0., 0., 0., 0., 0., 0.],\n       [0., 0., 0., 0., 0., 0.],\n       [0., 0., 0., 0., 0., 0.],\n       [0., 0., 0., 0., 0., 0.],\n       [0., 0., 0., 0., 0., 0.],\n       [0., 0., 0., 0., 0., 0.]])"
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sktime.distances import LowerBounding\n",
    "\n",
    "x = np.zeros((6, 6))\n",
    "y = np.zeros((6, 6))  # Create dummy data to show the matrix\n",
    "\n",
    "LowerBounding.NO_BOUNDING.create_bounding_matrix(x, y)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "Above shows a matrix that maps each index in 'x' to each index in 'y'. Dtw without\n",
    "bounding will consider all of these indexes (indexes in bound we define as finite\n",
    "values (0.0)). However, we can change the indexes that are considered using\n",
    "Sakoe-Chibas bounding like so:"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "outputs": [
    {
     "data": {
      "text/plain": "array([[ 0.,  0.,  0.,  0., inf, inf],\n       [ 0.,  0.,  0.,  0.,  0., inf],\n       [ 0.,  0.,  0.,  0.,  0.,  0.],\n       [ 0.,  0.,  0.,  0.,  0.,  0.],\n       [inf,  0.,  0.,  0.,  0.,  0.],\n       [inf, inf,  0.,  0.,  0.,  0.]])"
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "LowerBounding.SAKOE_CHIBA.create_bounding_matrix(x, y, sakoe_chiba_window_radius=0.5)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "The matrix that is produced follows the same concept as no bounding where each index\n",
    "between x and y are assigned a value. If the value is finite (0.0) it is considered\n",
    "inbound and infinite out of bounds. Using Sakoe-Chiba bounding matrix with a window\n",
    "radius of 1 we can see we get a diagonal from 0,0 to 5,5 where values inside the\n",
    " window are 0.0 and values outside are infinite. This reduces the compute time of\n",
    " dtw as we are considering 12 less potential indexes (12 values are infinite).\n",
    "<br><br>\n",
    "As mentioned there are other bounding techniques that use different 'shapes' over the\n",
    "matrix such a Itakuras parallelogram which as the name implies produces a parallelogram\n",
    "shape over the matrix."
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "outputs": [
    {
     "data": {
      "text/plain": "array([[ 0.,  0., inf, inf, inf, inf],\n       [inf,  0.,  0.,  0., inf, inf],\n       [inf,  0.,  0.,  0., inf, inf],\n       [inf, inf,  0.,  0.,  0., inf],\n       [inf, inf,  0.,  0.,  0., inf],\n       [inf, inf,  0.,  0.,  0.,  0.]])"
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "LowerBounding.ITAKURA_PARALLELOGRAM.create_bounding_matrix(x, y, itakura_max_slope=0.3)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "With that base introductory to bounding algorithms and why we may want to use them\n",
    "how do we use it in our distance computation. There are two ways:"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Dynamic time warping distance with Sakoe-Chiba:  364.7412646456549\n",
      "Dynamic time warping distance with Itakura parallelogram:  389.3428989579974\n",
      "Dynamic time warping distance with Sakoe-Chiba:  364.7412646456549\n"
     ]
    }
   ],
   "source": [
    "# Create two random unaligned time series to better illustrate the difference\n",
    "\n",
    "rng = np.random.RandomState(42)\n",
    "n_timestamps, n_features = 10, 19\n",
    "x = rng.randn(n_timestamps, n_features)\n",
    "y = rng.randn(n_timestamps, n_features)\n",
    "\n",
    "# First we can specify the bounding matrix to use either via enum or int (see\n",
    "# documentation for potential values):\n",
    "print(\n",
    "    \"Dynamic time warping distance with Sakoe-Chiba: \",\n",
    "    distance(x, y, metric=\"dtw\", lower_bounding=LowerBounding.SAKOE_CHIBA, window=1.0),\n",
    ")  # Sakoe chiba\n",
    "print(\n",
    "    \"Dynamic time warping distance with Itakura parallelogram: \",\n",
    "    distance(x, y, metric=\"dtw\", lower_bounding=2, itakura_max_slope=0.2),\n",
    ")  # Itakura parallelogram using int to specify\n",
    "print(\n",
    "    \"Dynamic time warping distance with Sakoe-Chiba: \",\n",
    "    distance(x, y, metric=\"dtw\", lower_bounding=LowerBounding.NO_BOUNDING),\n",
    ")  # No bounding"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
